<template>
  <div>
    <!-- <section class="echartsBox">
      <chartBox
        ref="chart1Ref"
        :option="equipmentChangeOption"
        :select-option="completeOrderList"
        :placeholder="'请选择订单'"
        :signChartName="EQUIPMENT_CHANGE_CHART"
        :defaultOrderInfo="defaultOrderInfo"
        @updateSelect="handleChangeSelect"
      />
    </section> -->

    <section class="echartsBox">
      <!-- 营业额统计：暂时限制一个月内 -->
      <chartBox :option="turnoverChangeOption" style="width: 100%" />
    </section>
  </div>
</template>

<script setup lang="ts">
import { getTurnoverChangeReq } from '@/api/businessDataChart/index'
import { useTurnoverChange } from './hooks/useTurnoverChart'
import chartBox from './components/chartBox.vue'

// 时间搜索范围 - 默认一个月
const searchTimeRange = {
  begin: '2025-09-13',
  end: '2025-10-13'
}

const { turnoverChangeOption, setTurnoverChangeOption } = useTurnoverChange()

// 页面初始化获取图表 - 点搜索
onMounted(() => {
  initData()
})

// 获取所有图表数据
const initData = async () => {
  try {
    // 1 - 获取营业额数据
    const res1 = await getTurnoverChangeReq({ ...searchTimeRange })
    if (res1.code === 1) {
      // 设置图的数据
      setTurnoverChangeOption(res1.data.dateList, res1.data.turnoverList, '营业额数据图')
    }
  } catch (error) {}
}
</script>

<style lang="scss" scoped>
.echartsBox {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
}
</style>
